import { defineStore } from 'pinia'

import { getcateGoryList, type categoryL1List,type bannerList5,type categoryGroupList,getcateList,getPagingData  } from '@/api/cateGory'

interface cateGoryLis1{
    categoryL1List:categoryL1List[],
    bannerList1:bannerList5[],
    categoryGroupList:categoryGroupList[],
    ImageList:bannerList5[]
}
export const usecateGoryStore = defineStore('cateGory', {
    state: ():cateGoryLis1 => {
      return { 
        categoryL1List: [],
        bannerList1:[],
        categoryGroupList:[],
        ImageList:[]
    }
    },
    actions: {
        // 获取列表数据 及 初始化动态展示数据
      async increment() {
        try {
            const request = await getcateGoryList()

            this.categoryL1List = request.categoryL1List || []


        } catch (error) {
            return Promise.reject(error)
        }
      },
      async getPagingListdData(id:number){
        try {
           const result = await getcateList(id)
           
           this.categoryGroupList = result.categoryGroupList as [] || []
           
           this.ImageList = result.currentCategory.bannerList as [] || [] 

        } catch (error) {
            return Promise.reject(error)
        }
     }, 
    },
    getters:{}
  })